﻿@model OT.Areas.Admin.Models.QuestionTypes
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button>
    <h3 id="myModalLabel">Edit Question Type</h3>
</div>
@Html.HiddenFor(model => model.QuestionTypeID, new { id = "HDFID" })
<div class="modal-body">
    <div id="alert_modal">
        @Html.ValidationSummary()
    </div>
    <div class="form-horizontal" role="form">
        <div class="form-group">
            <div class="col-lg-15">
                <div id="divMsgEdit"></div>
                </div>
            </div>
        <div class="form-group" id="divQuestionType">
            <label class="col-lg-3 control-label"></label>
            <div class="col-lg-5">
                @Html.TextBoxFor(model => model.QuestionType1, new { @maxlength = "50",@class="form-control",@placeholder="Enter Question Type" })
                @Html.ValidationMessageFor(model => model.QuestionType1)
            </div>
        </div>
    </div>
</div>
<div class="modal-footer">
    <button class="btn btn-default" type="submit" id="btnEdit"><i class="icon-cog"></i>Save</button>
    <button class="btn btn-default" data-dismiss="modal" aria-hidden="true"><i class="icon-off"></i>Cancel</button>
</div>
<script type="text/javascript">
    $("#btnEdit").click(function (e) {
        var QuestionTypeID = $("#HDFID").val();
        var QuestionType = $("#QuestionType1").val();
        e.preventDefault();
        if (QuestionType == '') {
            showMsg('divMsgEdit', 'Please Enter Required Field Value', 'danger');
            (QuestionType == 0) ? $('#divQuestionType').addClass('has-error') : $('#divQuestionType').removeClass('has-error');
        }
        else {
            $.ajax({
                url: "/Admin/QuestionType/Edit?QuestionTypeID=" + QuestionTypeID + "&QuestionType=" + QuestionType,
                type: "POST",
                success: function (result) {
                    if (result != "NotValid") {
                        $('#modalDiv').modal('hide');
                        showMsg('divMsgIndex', 'Record Successfuly Updated', 'success');
                        loadPage(1, 10, '');
                    }
                    else {
                        showMsg('divMsgEdit', 'failed to Update record !! Error', 'danger');
                    }
                },
                error: function (data) {
                }
            });
        }
        return false;
    });
</script>
